
package gnu.org.twanoh.app;

import static gnu.org.twanoh.app.ActivityState.ON_CREATE;
import static gnu.org.twanoh.app.ActivityState.ON_STOP;
import static gnu.org.twanoh.app.ActivityState.*;
import gnu.org.twanoh.statemachine.StateMap;

import java.util.EnumSet;

public final class ActivityStateMapFactory {

    private static StateMap<ActivityState> stateMap;

    public final static StateMap<ActivityState> getStateMap() {

        if (stateMap == null) {

            stateMap = new StateMap<ActivityState>();

            stateMap.put(ON_CREATE, EnumSet.of(PRE_CREATE, ON_STOP));
            stateMap.put(ON_START, EnumSet.of(ON_CREATE, ON_RESTART));
            stateMap.put(ON_RESUME, EnumSet.of(ON_START, ON_PAUSE));
            stateMap.put(ON_PAUSE, EnumSet.of(ON_RESUME));
            stateMap.put(ON_STOP, EnumSet.of(ON_PAUSE));
            stateMap.put(ON_RESTART, EnumSet.of(ON_STOP));
            stateMap.put(ON_DESTROY, EnumSet.of(ON_STOP));

        }

        return stateMap;

    }
}
